<template>
	<div id="wrapper">
		<!--使用组件-->
		<home-header :city="city"></home-header>
		<home-swiper :imgUrl="swiperList"></home-swiper>
		<home-icons :icons="iconsList"></home-icons>
		<home-other :likeData="likeData" :liData="liData"></home-other>
		<home-week :weekList="weekData"></home-week>
		<home-footer></home-footer>  
	</div>
</template>

<script>
	//引入组件
	import HomeHeader from '@/pages/components/Header'
	import HomeSwiper from '@/pages/components/Swiper'
	import HomeIcons from '@/pages/components/Icons'
	import HomeOther from '@/pages/components/Other'
	import HomeWeek from '@/pages/components/Week'
	import HomeFooter from '@/pages/components/Footer'
	//请求数据
	import axios from 'axios'
	
	
	export default{
		name:"home",
		components:{//注册组件
			HomeHeader,
			HomeSwiper,
			HomeIcons,
			HomeOther,
			HomeWeek,
			HomeFooter 
		},
		data(){//数据
			return{
				city:"",
				swiperList:[],
				iconsList:[],
				likeData:[],
				liData:[],
				weekData:[]
			}
		},
		methods:{
			getHomeInfo(){
				//请求数据
				axios.get('static/moke/index.json').then(this.getSucc)
			},
			getSucc(res){//对数据进行处理
				var res=res.data//请求的结果
				if(res.ret&&res.data){
					this.city=res.data.city;//Header中的city
					this.swiperList=res.data.imgUrl//swiper的数据
					this.iconsList=res.data.iconsUrl//icons的数据
					this.likeData=res.data.likeData//猜你喜欢数据
					this.liData=res.data.liData
					this.weekData=res.data.weekData
				}
			},
		},
		mounted(){//生命周期钩子(一般向后端发起请求，对请求的数据做业务处理)
				this.getHomeInfo();
			}
	}
</script>

<style lang="stylus" scoped>
	#wrapper{height:1000px;}

</style>